<#include '/admin/sonheader.html' >
<style>
  .layui-input{
    width: 70%;
  }
</style>

<div class="main">
    <!--表单区域  -->
	<form class="layui-form layui-form-pane" action="" id="editSubjectForm" enctype="multipart/form-data">
		<input type="hidden" name="id" value="${subject.id}" >
  		<div class="layui-form-item">
    		<label class="layui-form-label">标题</label>
    		<div class="layui-input-block">
      			<input type="text" name="title" maxlength="20" lay-verify="title" autocomplete="off"  class="layui-input" value="${subject.title}">
    		</div>
  		</div>
  		
  		<div class="layui-form-item">
    		<label class="layui-form-label">排序</label>
    		<div class="layui-input-block">
      			<input type="text" maxlength="5" name="sort" value="${subject.sort}"  lay-verify="sort" value="1" autocomplete="off"  class="layui-input" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="float:left;">
      			<div class="layui-form-mid layui-word-aux">控制专题横幅的显示顺序</div>
    		</div>
  		</div>
  		
  		<div class="layui-form-item">
    		<label class="layui-form-label">显示</label>
    		<div class="layui-input-block">
      			<input type="radio" name="is_display" value="0" title="显示" <#if subject.is_display?? && subject.is_display==0>checked="checked"</#if>>
      			<input type="radio" name="is_display" value="1" title="不显示" <#if subject.is_display?? && subject.is_display==1>checked="checked"</#if>>
    		</div>
  		</div>
  		
  		<div class="layui-form-item">
    		<label class="layui-form-label">横幅</label>
    		<div class="layui-input-block">
    			<input type="hidden" name="banner" value="${subject.banner!''}">
    			<input type="file" name="file" maxlength="50" class="_upfile" > 
      			<div class="layui-form-mid layui-word-aux">在专题页面显示的图片横幅 建议大小 1200px*300px</div>
    		</div>
  		</div>
  		
  		<div class="layui-layer-btn layui-layer-btn-" style="padding:8px 12px;"> 
  			<a class="layui-layer-btn0" type="submit" lay-submit="" lay-filter="editSubject">保存</a>
  			<a class="layui-layer-btn1">取消</a>
  		</div>
  	</form>
</div>
<script type="text/javascript">	
var index = parent.layer.getFrameIndex(window.name);

layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form()
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;

    //自定义验证规则
    form.verify({
      title: function(value){
        if($.trim(value)==""){
          return '标题至少得5个字符啊';
        }
      },
      sort:function(value){
    	  if($.trim(value)==""){
    		  return "排序不能为空"
    	  }
      }
    });
    
    $(".layui-layer-btn1").click(function(){
    	parent.layer.close(index);
    });
    
    //监听提交
    form.on('submit(editSubject)', function(data){
    	var options = {
   			url:ctx+"/core/admin/subject/save-edit.do?",
   			type:"post",
   			dataType:"json",
   			success:function(data){
   				if(data.result==1){	
   					$.Loading.success(data.message);
   					parent.layer.close(index); //再执行关闭        
   					parent.table.ajax.url(ctx+"/core/admin/subject/list-json.do").load();
   				}
   			}
   		};
   		$("#editSubjectForm").ajaxSubmit(options);
       return false;
    });
});
</script>

